// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()
const db = cloud.database()
exports.main = async(event, context) => {
  const a = await db.collection('Teacher').where({
    teaDept: event.userDept
  }).count()
  const b = await db.collection('Topic').where({
    dept: event.userDept
  }).count()
  const c = await db.collection('Student').where({
    stuDept: event.userDept
  }).count()
  const d = await db.collection('Student').where({
    stuDept: event.userDept,
    stuState: 1
  }).count()
  const e = await db.collection('Student').where({
    stuDept: event.userDept,
    stuState: 0
  }).count()
  const f = await db.collection('Topic').where({
    dept: event.userDept,
    ktzt: 0
  }).count()
  const g = await db.collection('Topic').where({
    dept: event.userDept,
    ktzt: 1
  }).count()
  const h = await db.collection('Topic').where({
    dept: event.userDept,
    ktzt: 2
  }).count()
  const i = await db.collection('Teacher').where({
    teaDept: event.userDept,
    teaState: 1
  }).count()
  const j = await db.collection('Teacher').where({
    teaDept: event.userDept,
    teaState: 0
  }).count()
  return {
    a: a.total,
    b: b.total,
    c: c.total,
    d: d.total,
    e: e.total,
    f: f.total,
    g: g.total,
    h: h.total,
    i: i.total,
    j: j.total
  }
}